package cn.kshost.zqyg.manager.service.impl;

import cn.kshost.zqyg.manager.mapper.BrandMapper;
import cn.kshost.zqyg.manager.service.BrandService;
import cn.kshost.zqyg.model.entity.product.Brand;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BrandServiceImpl implements BrandService {

    @Autowired
    private BrandMapper brandMapper;
    @Override
    public PageInfo<Brand> findByPage(Integer pageNum, Integer pageSize) {
        //开启分页拦截
        PageHelper.startPage(pageNum, pageSize);
        //查询结果
        List<Brand>  brands=  brandMapper.selectByPage();
        //打包数据
        PageInfo<Brand> brandPageInfo = new PageInfo<>(brands);
        //返回数据
        return brandPageInfo;
    }

    @Override
    public void addBrand(Brand brand) {
        brandMapper.insertBrand(brand);
    }

    @Override
    public void modifyBrand(Brand brand) {

        brandMapper.updateBrand(brand);
    }

    @Override
    public void deleteBrand(Brand brand) {
        brandMapper.deleteBrand(brand);
    }

    @Override
    public List<Brand> getAllBrandList() {
        List<Brand>  brands=  brandMapper.selectByPage();
        return brands;
    }


}
